package cn.tedu.util;

import org.springframework.beans.BeanUtils;

/**
 * pojo转换工具, 通过泛型的应用把传进来的对象属性复制给目标类型对象
 * @author Kiven
 */
public class PojoConvert {

    public static <T>T convert(Object o, Class<T> cls){
        T t = null;
        try {
            t = cls.newInstance();
            BeanUtils.copyProperties(o,t);
            return t;
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        return null;
    }


}
